﻿using Breeze.WebApi2;
using Breeze.ContextProvider.EF6;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Entity;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using BreezeEditor.Models;
using Breeze.ContextProvider;
using Newtonsoft.Json.Linq;

namespace BreezeEditor.Controllers
{
    [BreezeController]
    public class PersonController : ApiController
    {
        EFContextProvider<TestContext> _contextProvider = new EFContextProvider<TestContext>();
        // GET api/<controller>
        [HttpGet]
        public string Metadata()
        {
            return _contextProvider.Metadata();
        }

        // ~/api/todos/Todos
        // ~/api/todos/Todos?$filter=IsArchived%20eq%20false&$orderby=CreatedAt
        [HttpGet]
        public IQueryable<Person> Persons()
        {
            return _contextProvider.Context.Persons;
        }

        // ~/api/todos/SaveChanges
        [HttpPost]
        public SaveResult SaveChanges(JObject saveBundle)
        {
            return _contextProvider.SaveChanges(saveBundle);
        }
    }
}